﻿//--------------------------------------------------
// Create WoW.Armory Javascript Object
//--------------------------------------------------
if ("undefined" == typeof (WoW)) {
    WoW = new Object();
}

if ("undefined" == typeof (WoW.Armory)) {
    WoW.Armory = new Object();
    WoW.Armory.Interop = new Gadget.Interop.Service();
    WoW.Armory.Armory = null;
}

WoW.Armory.Init = function () {
    try {
        //Add parameters on WoW.Armory.WoW.Armory constructor
        this.Interop.Service.AddConstructorParam("US");
        this.Interop.Service.AddConstructorParam("Nazjatar");
        this.Interop.Service.AddConstructorParam("Thirith");

        //Load .NET Assembly(WoW.Armory.Armory) with parameters
        this.Armory = this.Interop.Service.LoadTypeWithParams("D:\\Mesh\\Projects\\WoW Armory\\WoW.Armory\\HTMLTest\\bin\\WoW.Armory.dll", "WoW.Armory.Armory", false);
        this.Armory = this.Armory.Load();

        var frame = document.getElementById("Battlegroup");
        frame.innerHTML = this.Armory.CharacterInfo.Character.Battlegroup;
        frame = document.getElementById("Realm");
        frame.innerHTML = this.Armory.CharacterInfo.Character.Realm;
        frame = document.getElementById("Prefix");
        frame.innerHTML = this.Armory.CharacterInfo.Character.Prefix;
        frame = document.getElementById("CharName");
        frame.innerHTML = this.Armory.CharacterInfo.Character.Name;
        frame = document.getElementById("GuildName");
        frame.innerHTML = this.Armory.CharacterInfo.Character.GuildName;
        frame = document.getElementById("ClassName");
        frame.innerHTML = "Level " + this.Armory.CharacterInfo.Character.Level + " " + this.Armory.CharacterInfo.Character.Race + " " + this.Armory.CharacterInfo.Character.ClassName;
        frame = document.getElementById("ClassImage");
        frame.src = this.Armory.CharacterInfo.Character.ImageURL;
    }
    catch (e) {
        var frame = document.getElementById("gFrame");
        frame.innerText = e.message;
    }
}